import * as types from '../mutation-types'
import {_get} from '@/api/index'


//定义变量
const state = {
  foodList: [],
  banner: [],
};

//变量改变方法
const getters = {
  foodList: state => state.foodList,
  banner: state => state.banner
};

//获取变量请求
const actions = {
  getFoodList({commit}, {other}) {

    commit('getFoodList', {other})
  },
  banner({commit}) {
    // debugger
    _get({url: '/index/banner'}).then((res) => {
      let data = res.data;
      commit('getBanner', data)
    })
  }
}

//变量处理业务逻辑层
const mutations = {
  getFoodList(state, list) {
    return state.foodList = list
  },
  getBanner(state, banner) {
    return state.banner = banner;
  }
}

export default {
  getters,
  actions,
  state,
  mutations
}
